#!/bin/bash
# Dumbo Benchmark Demo Script

set -e

echo "=========================================="
echo "Dumbo Benchmark Demo"
echo "=========================================="

# Check if we're in the right directory
if [ ! -f "fabfile.py" ]; then
    echo "Error: Please run this script from the benchmark directory"
    echo "cd /home/dumbo/benchmark && ./demo.sh"
    exit 1
fi

# Check dependencies
echo "Checking dependencies..."
python3 -c "import fabric" 2>/dev/null || {
    echo "Installing Python dependencies..."
    pip install -r requirements.txt
}

go version >/dev/null 2>&1 || {
    echo "Error: Go is not installed or not in PATH"
    exit 1
}

tmux -V >/dev/null 2>&1 || {
    echo "Error: tmux is not installed"
    exit 1
}

echo "✓ All dependencies are available"

# Demo 1: Local test
echo ""
echo "=========================================="
echo "Demo 1: Local Dumbo Test"
echo "=========================================="
echo "Running local test with 4 nodes for 15 seconds..."
fab local --nodes=4 --duration=15 --batch_size=50

echo ""
echo "Local test completed! Check results in:"
echo "ls -la ../data/"

# Demo 2: Show available commands
echo ""
echo "=========================================="
echo "Demo 2: Available Commands"
echo "=========================================="
echo "Available Fabric commands:"
fab --list

echo ""
echo "=========================================="
echo "Demo completed!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Check local test results: ls -la ../data/"
echo "2. Run AWS test: fab aws --nodes=4 --duration=30"
echo "3. Run Alibaba test: fab alibaba --nodes=4 --duration=30"
echo "4. View help: fab <command> --help"
echo ""
echo "For more information, see README.md"

